/*
 * LightFence.h
 *
 *  Created on: Jan 2, 2009
 *      Author: Carmine Red
 */

#ifndef LIGHTFENCE_H_
#define LIGHTFENCE_H_

#include "AnchorPoint.h"
#include "nmeRecArray.h"

//#define MAX_ENEMIES	256	/*defines max num of enemies allowed at any one time*/

class LightFence
{
private:
	AnchorPoint* anchor1;
	AnchorPoint* anchor2;

	int myLength;
	int myDamage;
	int myColor;

	float cooldownLength;	/*this is the amount of time we set cooldowns to
							after the light fence pulses*/

	float currentCooldown;
	bool checkAttack;		/*this bool is set after the first "above-below"
							check on a newly activated fence so that subsequent
							updates can start looking for damage opportunities.*/

public:

	// MAY WANT TO MAKE nmeRec

	nmeRecArray	nmeRec;	// this class handles the data on the enemies
										// that the fence cares about

	LightFence();

	void cleanUp();

	void setAnchorOne(AnchorPoint* toUse);
	void setAnchorTwo(AnchorPoint* toUse);

	void setmyLength(int val) {myLength = val;}
	int getmyLength() {return myLength;}
	void setmyDamage(int val) {myDamage = val;}
	int getmyDamage() {return myDamage;}
	void setmyColor(int val) {myColor = val;}
	int getmyColor() {return myColor;}

	void setcooldownLength(float val) {cooldownLength = val;}
	float getcooldownLength() {return cooldownLength;}

	void setcheckAttack(bool val) {checkAttack = val;}
	bool getcheckAttack() {return checkAttack;}

	void render();

	/*
	NOTE:
	This is how we'll go through comparing the game characters (enemies) to the light
	fences: first we'll check if the light fence is active.

	If one is, then we'll run through each game character and check if it is within
	range of the fence.

	If it is, then we'll set/update their status with regards to whether they're above
	or below the fence. There are two conditions possible: above or below.

	THIS STATUS INFO WILL BE KEPT ON THE LIGHTFENCE, NOT THE ENEMY.

	IF the checkAttack property is false (meaning the fence was previously inactive),
	then we set it to active and we'd normally be done with the checking process.
		OTHERWISE we're allowed to check if there were any changes. We'll cycle through
			the changes.
			IF there were thing that crossed, we then choose the target(s), deal the
			damage, set the cooldown to start counting down again, and erase our enemy
			status memory.
	*/
	void update();

	/*
	This function returns whether a game character is close enough to the light fence to
	care about checking it
	*/
	bool isInRange(int xLoc, int yLoc);

	/*
	This function return whether a game character is on one side of the light fence
	(above, or true) or the other side (below, or false).
	This is important because it is used to determine whether a game character has
	crossed the fence and may take damage.
	*/
	bool isAbove(int xLoc, int yLoc);

	/*
	returns whether the light fence is active or not by checking the currentCooldown against 0;
	*/
	bool isActive();

	void triggerDamage();	// this makes the fence act as if it caused damage and all the
							// other stuff that comes with it
};

#endif /* LIGHTFENCE_H_ */
